<template>
  <view class="page">
    <!-- Top header background -->
    <view class="header" :style="{ paddingTop: statusBarPx + 'px' }">
      <image class="top-bg" src="@/static/images/tactics/top-bg.png" mode="widthFix" />
    </view>

    <scroll-view scroll-y class="scroll" :style="{ paddingTop: statusBarPx + 16 + 'px' }">
      <!-- Sections rendered by v-for -->
      <view class="section" v-for="(module, moduleIndex) in modules" :key="moduleIndex">
        <view class="section-hd">
          <image class="left-icon" src="/static/images/tactics/left-icon.png" mode="widthFix" />
          <text class="section-title">{{ module.title }}</text>
        </view>
        <view class="card-grid">
          <view class="card" v-for="card in module.items" :key="card.key" @click="go(card.key)">
            <image class="card-img" :src="card.img" mode="widthFix" />
          </view>
        </view>
      </view>

      <view style="height: 40rpx"></view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    const sys = uni.getSystemInfoSync()
    return {
      statusBarPx: sys.statusBarHeight || 0,
      modules: [
        {
          title: 'AI 功能',
          items: [
            {
              key: 'code',
              img: '/static/images/tactics/ai-code-strategy.png',
              title1: '代码生成',
              title2: '策略',
            },
            {
              key: 'research',
              img: '/static/images/tactics/research-strategy.png',
              title1: '自研策略',
            },
            {
              key: 'settings',
              img: '/static/images/tactics/strategy-settings.png',
              title1: '策略设置',
            },
          ],
        },
        {
          title: '策略进度',
          items: [
            {
              key: 'crypto',
              img: '/static/images/tactics/crypto-module.png',
              title1: '加密版块',
            },
            {
              key: 'stocks',
              img: '/static/images/tactics/stocks-module.png',
              title1: '股票版块',
            },
            {
              key: 'forex',
              img: '/static/images/tactics/forex-module.png',
              title1: '外汇版块',
            },
          ],
        },
      ],
    }
  },
  methods: {
    go(name) {
      uni.showToast({ title: `进入：${name}`, icon: 'none' })
    },
  },
}
</script>

<style lang="scss" scoped>
.page {
  position: relative;
  min-height: 100vh;
  background: #fff;
}
.header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}
.top-bg {
  width: 100%;
}
.scroll {
  box-sizing: border-box;
}
.section {
  padding: 24px 16px 0;
}
.section-hd {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.left-icon {
  width: 36rpx;
}
.section-title {
  font-size: 28rpx;
  font-weight: 700;
  color: #1f2937;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.card {
  position: relative;
  background: #f6f7fb;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
.card-img {
  width: 100%;
  height: 100%;
}
.card-title {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 18px;
  font-weight: 800;
  color: #6d77ff;
}
.card:nth-child(2) .card-title {
  color: #2d7ef7;
}
.card:nth-child(3) .card-title {
  color: #ff9b3b;
}
.section:nth-of-type(2) .card:nth-child(1) .card-title {
  color: #7a6dff;
}
.section:nth-of-type(2) .card:nth-child(2) .card-title {
  color: #2d7ef7;
}
.section:nth-of-type(2) .card:nth-child(3) .card-title {
  color: #ff9b3b;
}
.br {
  display: block;
  height: 0;
}
</style>
